<template>
  <page-header-wrapper :title="false">
    <a-card title="商标数据统计">
      <div class="table-page-search-wrapper">
        <a-form-model
          layout="inline"
          :model="queryParam"
        >
          <a-row :gutter="15">
            <a-col :md="6" :sm="24">
              <a-form-model-item label="专利名称">
                <a-input v-model="queryParam['filter[zl_name]']"/>
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-model-item label="合同编号">
                <a-input v-model="queryParam['filter[phone]']"/>
              </a-form-model-item>
            </a-col>
            <template v-if="advanced">
              <a-col :md="6" :sm="24">
                <a-form-model-item label="业务编号">
                  <a-input v-model="queryParam['filter[tm_name]']"/>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="提交时间">
                  <a-range-picker />
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="领取时间">
                  <a-range-picker />
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="所属顾问">
                  <a-select
                    show-search
                    v-model="queryParam['filter[adviser_uid]']"
                    placeholder="输入要搜索的顾问姓名"
                    :default-active-first-option="false"
                    :show-arrow="false"
                    :filter-option="false"
                    :not-found-content="null"
                    @search="onSearch"
                  >
                    <a-select-option v-for="(item,index) in searchSource" :key="index" :value="index">
                      {{ item }}
                    </a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="流程状态">
                  <a-select v-model="queryParam['filter[customer_status]']" :default-value="0">
                  </a-select>
                </a-form-model-item>
              </a-col>
            </template>
            <a-col :md="!advanced && 8 || 24" :sm="24">
                <span class='table-page-search-submitButtons' :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
                  <a-button type="primary" @click="$refs.table.refresh(true)">搜索</a-button>
                  <a-button style="margin-left: 8px" @click="resetForm">重置</a-button>
                  <a @click="toggleAdvanced" style="margin-left: 8px">
                    {{ advanced ? '收起' : '展开' }}
                    <a-icon :type="advanced ? 'up' : 'down'" />
                  </a>
                </span>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
      <div class="table-operator">
        <s-table
          bordered
          size="middle"
          ref="table"
          :row-key="(record) => record.cb_id"
          :columns="businessColumns"
          :data="businessData"
        >
          <template slot="contract_no" slot-scope="text,record">
            {{text}}<br>
            {{record.business_no}}
          </template>
          <template slot="adviser" slot-scope="text, record">
            <a-tag>{{text}}</a-tag><br>
            <a-tag>{{record.group_type}}</a-tag><br>
            <a-tag>{{record.leader}}</a-tag>
          </template>
          <template slot="history" slot-scope="text">
            <a @click="historyModal">{{text}}</a>
          </template>
          <template slot="status">
            <a-button size="small" icon="edit" type="default" @click="changeStatus">提交材料</a-button>
          </template>
          <template slot="official_fee" slot-scope="text,record">
            <a-tag color="red">官费：{{text}}</a-tag><br>
            <a-tag color="red">价格：{{record.price}}</a-tag><br>
          </template>
          <template slot="action">
            <a-button-group>
              <a-button type="primary" size="small" @click="downloadModal">下载</a-button>
              <a-button type="danger" size="small" @click="uploadModal">上传</a-button>
              <a-button type="default" size="small" @click="$router.push({ name: 'TaskEdit', params: { id: 15 } })">查看</a-button>
            </a-button-group>
          </template>
        </s-table>
      </div>
    </a-card>
    <a-modal
      centered
      title="上传材料"
      v-model="uploadVisible"
    >
      <a-form-model
        :model="uploadForm"
        :label-col="labelCol"
        :wrapper-col="wrapperCol"
      >
        <a-form-model-item label="业务名称">
          <a-input disabled v-model="uploadForm.business_name" type="text" />
        </a-form-model-item>
        <a-form-model-item label="整理后材料">
          <a-upload
            name="file"
            :multiple="true"
            action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
          >
            <a-button type="danger"> <a-icon type="upload" />上传整理后的材料</a-button>
          </a-upload>
        </a-form-model-item>
      </a-form-model>
    </a-modal>
    <a-modal
      centered
      title="下载材料"
      v-model="downloadVisible"
    >
      <a-alert>
        <template slot="message">
          整理后的材料：<a>鑫彭：秦双-HT20210711DSU99M-实用编写（包授权）-475+150-一种可拉伸展开的图书馆书架-马小艳.zip</a>
        </template>
      </a-alert>
      <a-divider />
      <a-descriptions :column="1">
        <a-descriptions-item label="申请主体"></a-descriptions-item>
        <a-descriptions-item label="身份证复印件"></a-descriptions-item>
        <a-descriptions-item label="营业执照复印件（加盖公章）"></a-descriptions-item>
        <a-descriptions-item label="联系电话"></a-descriptions-item>
        <a-descriptions-item label="技术交底书"></a-descriptions-item>
        <a-descriptions-item label="费减信息"></a-descriptions-item>
        <a-descriptions-item label="（个人申请）收入证明、（公司申请）上一年度企业纳税申报表"></a-descriptions-item>
      </a-descriptions>
    </a-modal>
    <a-modal
      centered
      v-model="historyVisible"
      title="历史信息"
      :footer="null"
    >
      <a-timeline>
        <a-timeline-item>【提交材料】马婷，提交了材料 2015-09-01</a-timeline-item>
        <a-timeline-item>【提交材料】马婷，提交了材料 2015-09-01</a-timeline-item>
        <a-timeline-item>【提交材料】马婷，提交了材料 2015-09-01</a-timeline-item>
      </a-timeline>
    </a-modal>
    <a-modal
      centered
      v-model="submitVisible"
      title="编辑状态"
    >
      <a-form-model
        :model="statusForm"
      >
        <a-form-model-item>
          <a-radio-group>
            <!--            <a-radio value="1">-->
            <!--              材料反馈-->
            <!--            </a-radio>-->
            <a-radio value="2">
              甲方确认
            </a-radio>
            <a-radio value="3">
              乙方专利师确认
            </a-radio>
          </a-radio-group>
        </a-form-model-item>
        <a-form-model-item>
          <a-textarea :rows="4" placeholder="请输入材料备注"></a-textarea>
        </a-form-model-item>
      </a-form-model>
    </a-modal>
  </page-header-wrapper>
</template>

<script>
import { STable } from '@/components'
import attorneyColumns from '@/columns/patent.attorney'
import { onCompletionAdviser } from '@/api/patent.process'

export default {
  components: {
    STable
  },
  name: 'TradeStats',
  data () {
    return {
      labelCol: { span: 4 },
      wrapperCol: { span: 14 },
      queryParam: {},
      advanced: true,
      tab: '1',
      businessColumns: attorneyColumns.business,
      businessData: parameters => {
        return new Promise(resolve => {
          resolve({
            page: 1,
            page_size: 10,
            total_count: 1,
            data: [
              {
                cb_id: 1,
                patent_no: '20054545',
                contract_no: 'HT20210806F1OZKE',
                business_no: 'YW2021080680AJX0',
                business_name: '外观专利套餐（一个申请人）',
                official_fee: '2000.00',
                price: '4000.00',
                pt_name: '发明',
                adviser_name: '刘迪',
                patent_attorney: '',
                company: '天猫国际',
                history: '【提交材料】，zl凡悦悦，提交了材料',
                submit_time: '2020-07-15 23:23:23'
              },
              {
                cb_id: 2,
                patent_no: '20054545',
                contract_no: 'HT20210806F1OZKE',
                business_no: 'YW2021080680AJX0',
                business_name: '外观专利套餐（一个申请人）',
                official_fee: '2000.00',
                price: '4000.00',
                pt_name: '发明',
                adviser_name: '刘迪',
                patent_attorney: '胡浩',
                company: '天猫国际',
                history: '【提交材料】，zl凡悦悦，提交了材料',
                submit_time: '2020-07-15 23:23:23'
              }
            ]
          })
        })
      },
      uploadVisible: false,
      downloadVisible: false,
      submitVisible: false,
      historyVisible: false,
      uploadForm: {
        business_name: '实用担保套餐（1个申请人）'
      },
      statusForm: {},
      searchSource: []
    }
  },
  methods: {
    uploadModal () {
      this.uploadVisible = true
    },
    downloadModal () {
      this.downloadVisible = true
    },
    historyModal () {
      this.historyVisible = true
    },
    changeStatus () {
      this.submitVisible = true
    },
    exportModal () {
      this.exportVisible = true
    },
    toggleAdvanced () {
      this.advanced = !this.advanced
    },
    resetForm () {
      this.queryParam = {}
      this.$refs.table.refresh(true)
    },
    onSearch (searchText) {
      onCompletionAdviser(searchText).then(res => {
        this.searchSource = res.result.data
      })
    }
  }
}
</script>

<style scoped>

</style>
